[% WRAPPER default_statistics_page_wrapper.html title="Segmentation" %]

[% PROCESS segmentation_sizes_pie_chart.html %]
[% segmentation_sizes_pie_chart %]

[% PROCESS compare_segmentations_by_label.html %]
[% compare_segmentations_by_label %]

[% PROCESS box_plots.html %]
[% box_plots %]

<script>
    window.onload = function() {
      [% segmentation_sizes_pie_chart_on_window_load   %]
      [% compare_segmentations_by_label_on_window_load %]
      [% box_plots_on_window_load                      %]
    };
</script>

<h2><a name="Segmentation_state_emissions_and_assignments">Segmentation state emissions and assignments</a></h2>

<script type="text/javascript" class="init">

$(document).ready(function() {
    $('#segmentation_emssions_and_assignments').DataTable(
        {
            "iDisplayLength": 25,
        }
    );
} );

</script>

<table id="segmentation_emssions_and_assignments" class="display" cellspacing="0" width="80%">
<thead>
    <tr>
        <th>state   </th>
        <th>segmentation</th>
        <th>assignment </th>
        <th>average length</th>
        <th>min length</th>
        <th>max length</th>
        <th>num segmentation features</th>
        <th>CTCF    </th>
        <th>DNase1  </th>
        <th>H3K27ac </th>
        <th>H3K27me3</th>
        <th>H3K36me3</th>
        <th>H3K4me1 </th>
        <th>H3K4me2 </th>
        <th>H3K4me3 </th>
        <th>H3K9ac  </th>
        <th>H3K9me3 </th>
    </tr>
</thead>
<tbody>

[% FOR segmentation_state_emission IN segmentation_state_emissions %]

[% assignment   = segmentation_state_emission.fetch_segmentation_state_assignment.assignment   %]
[% segmentation = segmentation_adaptor.fetch_by_name(segmentation_state_emission.segmentation) %]

<tr>
    <td>[% segmentation_state_emission.state    %]</td>
    <td>[% segmentation.name %]</td>
    <td>[% segmentation_state_emission.fetch_segmentation_state_assignment.assignment    %]</td>
    <td align="right">
      [% 
        format_number(
          segmentation_statistic_adaptor
            .fetch_average_length_by_Segmentation_state(
              segmentation,
              segmentation_state_emission.state
            ).value
          )
      %]
    </td>
    <td align="right">
      [% 
        format_number( 
          segmentation_statistic_adaptor
            .fetch_min_length_by_Segmentation_state(
              segmentation, 
              segmentation_state_emission.state
            ).value
          )
      %]
    </td>
    <td align="right">
      [% 
        format_number( 
          segmentation_statistic_adaptor
            .fetch_max_length_features_by_Segmentation_state(
              segmentation, 
              segmentation_state_emission.state
            ).value
          )
      %]
    </td>
    <td align="right">
      [% 
        format_number( 
          segmentation_statistic_adaptor
            .fetch_num_segmentation_features_by_Segmentation_state(
              segmentation, 
              segmentation_state_emission.state
            ).value
          )
      %]
    </td>
    <td bgcolor="[% emission_to_rgb( segmentation_state_emission.CTCF )     %]">[% round_num( segmentation_state_emission.CTCF     ) %]</td>
    <td bgcolor="[% emission_to_rgb( segmentation_state_emission.DNase1 )   %]">[% round_num( segmentation_state_emission.DNase1   ) %]</td>
    <td bgcolor="[% emission_to_rgb( segmentation_state_emission.H3K27ac )  %]">[% round_num( segmentation_state_emission.H3K27ac  ) %]</td>
    <td bgcolor="[% emission_to_rgb( segmentation_state_emission.H3K27me3 ) %]">[% round_num( segmentation_state_emission.H3K27me3 ) %]</td>
    <td bgcolor="[% emission_to_rgb( segmentation_state_emission.H3K36me3 ) %]">[% round_num( segmentation_state_emission.H3K36me3 ) %]</td>
    <td bgcolor="[% emission_to_rgb( segmentation_state_emission.H3K4me1 )  %]">[% round_num( segmentation_state_emission.H3K4me1  ) %]</td>
    <td bgcolor="[% emission_to_rgb( segmentation_state_emission.H3K4me2 )  %]">[% round_num( segmentation_state_emission.H3K4me2  ) %]</td>
    <td bgcolor="[% emission_to_rgb( segmentation_state_emission.H3K4me3 )  %]">[% round_num( segmentation_state_emission.H3K4me3  ) %]</td>
    <td bgcolor="[% emission_to_rgb( segmentation_state_emission.H3K9ac )   %]">[% round_num( segmentation_state_emission.H3K9ac   ) %]</td>
    <td bgcolor="[% emission_to_rgb( segmentation_state_emission.H3K9me3 )  %]">[% round_num( segmentation_state_emission.H3K9me3  ) %]</td>
</tr>
[% END %]

</tbody>
</table>

[% END %]